News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.newscategorycourse.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
2.94 %2.94%
2.94% 2 / 68
 
NewsCategoryCourse
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
1.49 %1.49%
1.49% 1 / 67
 public function __construct($catID, $courses, $userID, $categorySettings = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function isInstalled($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function canSelectPeriod()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getNewsHeaderTitle($courseID = NULL, $type = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 31
 protected function echoNewsEntry($entry, $courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 21


       1                 : <?php                                                                                                                                                                                                                                          
       2                 : /*--------------------------------------------------------------------------+                                                                                                                                                                  
       3                 : This file is part of eStudy.                                                                                                                                                                                                                   
       4                 : news/classes/class.NewsCategoryCourses.inc.php                                                                                                                                                                                                 
       5                 : - Modulgruppe:  News                                                                                                                                                                                                                           
       6                 : - Beschreibung: Klasse für die News-Kategorie Kurse.                                                                                                                                                                                          
       7                 : - Version:      1.1.2.4,24/01/08                                                                                                                                                                                                               
       8                 : - Autor(en):    Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                                                                                                                
       9                 : +---------------------------------------------------------------------------+                                                                                                                                                                  
      10                 : This program is free software; you can redistribute it and/or                                                                                                                                                                                  
      11                 : modify it under the terms of the GNU General Public License                                                                                                                                                                                    
      12                 : as published by the Free Software Foundation; either version 2                                                                                                                                                                                 
      13                 : of the License, or any later version.                                                                                                                                                                                                          
      14                 : +---------------------------------------------------------------------------+                                                                                                                                                                  
      15                 : This program is distributed in the hope that it will be useful,                                                                                                                                                                                
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                                                                 
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                                                                  
      18                 : GNU General Public License for more details.                                                                                                                                                                                                   
      19                 : You should have received a copy of the GNU General Public License                                                                                                                                                                              
      20                 : along with this program; if not, write to the Free Software                                                                                                                                                                                    
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                                                                    
      22                 : +--------------------------------------------------------------------------*/                                                                                                                                                                  
      23                 :                                                                                                                                                                                                                                                
      24               1 : require_once ("class.newscategory.inc.php");                                                                                                                                                                                                   
      25                 :                                                                                                                                                                                                                                                
      26                 : /**                                                                                                                                                                                                                                            
      27                 :  * Klasse für die News-Kategorie Kurse.                                                                                                                                                                                                       
      28                 :  * @package eStudy.News                                                                                                                                                                                                                        
      29                 :  * @version 1.1.2.4, 24/01/08                                                                                                                                                                                                                  
      30                 :  * @author  Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                                                                                                                    
      31                 :  */                                                                                                                                                                                                                                            
      32               1 : class NewsCategoryCourse extends NewsCategory                                                                                                                                                                                                  
      33                 : {                                                                                                                                                                                                                                              
      34                 :    /**                                                                                                                                                                                                                                         
      35                 :      * HTML-Template                                                                                                                                                                                                                           
      36                 :      * @var Template                                                                                                                                                                                                                           
      37                 :      */                                                                                                                                                                                                                                        
      38                 :     private $newsTemplate;                                                                                                                                                                                                                     
      39                 :        /**                                                                                                                                                                                                                                     
      40                 :      * @var int                                                                                                                                                                                                                                
      41                 :      */                                                                                                                                                                                                                                        
      42                 :     private $userID;                                                                                                                                                                                                                           
      43                 :     /**                                                                                                                                                                                                                                        
      44                 :      * Konstruktor                                                                                                                                                                                                                             
      45                 :      * @param $userID int                                                                                                                                                                                                                      
      46                 :      */                                                                                                                                                                                                                                        
      47                 :     public function __construct($catID, $courses, $userID, $categorySettings = null)                                                                                                                                                           
      48                 :     {                                                                                                                                                                                                                                          
      49               0 :         parent::__construct($catID, $courses, $categorySettings);                                                                                                                                                                              
      50               0 :         $this->userID = $userID;                                                                                                                                                                                                               
      51               0 :         $this->newsTemplate = new Template(PATH_TO_ROOT."news/templates/newscourse.html");                                                                                                                                                     
      52               0 :     }                                                                                                                                                                                                                                          
      53                 :     /**                                                                                                                                                                                                                                        
      54                 :      * @see NewsCategory                                                                                                                                                                                                                       
      55                 :      */                                                                                                                                                                                                                                        
      56                 :     public function isInstalled($courseID)                                                                                                                                                                                                     
      57                 :     {                                                                                                                                                                                                                                          
      58               0 :         return (($courseID == 0)? true : false);                                                                                                                                                                                               
      59                 :     }                                                                                                                                                                                                                                          
      60                 :     /**                                                                                                                                                                                                                                        
      61                 :      * @see NewsCategory                                                                                                                                                                                                                       
      62                 :      */                                                                                                                                                                                                                                        
      63                 :     public function canSelectPeriod() {                                                                                                                                                                                                        
      64               0 :         return true;                                                                                                                                                                                                                           
      65                 :     }                                                                                                                                                                                                                                          
      66                 :     /**                                                                                                                                                                                                                                        
      67                 :      * @see NewsCategory                                                                                                                                                                                                                       
      68                 :      */                                                                                                                                                                                                                                        
      69                 :     public function getNewsHeaderTitle($courseID = null, $type = null) {                                                                                                                                                                       
      70               0 :         if(isset($this->news))                                                                                                                                                                                                                 
      71               0 :         {                                                                                                                                                                                                                                      
      72               0 :             $newsCount = $this->news["count"];                                                                                                                                                                                                 
      73               0 :             if ($newsCount > 1) $title = sprintf( $this->translate->_("%1\$s Kurse"), $newsCount);                                                                                                                                             
      74               0 :             elseif ($newsCount == 1) $title = $this->translate->_("1 Kurs");                                                                                                                                                                   
      75               0 :         }                                                                                                                                                                                                                                      
      76               0 :         else $title = $this->translate->_("Keine neuen Kurse");                                                                                                                                                                                
      77                 :                                                                                                                                                                                                                                                
      78               0 :         return $title;                                                                                                                                                                                                                         
      79                 :     }                                                                                                                                                                                                                                          
      80                 :                                                                                                                                                                                                                                                
      81                 :     /**                                                                                                                                                                                                                                        
      82                 :      * @see NewsCategory                                                                                                                                                                                                                       
      83                 :      */                                                                                                                                                                                                                                        
      84                 :     protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null)  {                                                                                                                                                
      85                 :         // Neue Mitteilungen                                                                                                                                                                                                                   
      86               0 :         if (isset($courseID) && isset($from) && isset($to) && isset($this->coursePreferences))                                                                                                                                                 
      87               0 :         {                                                                                                                                                                                                                                      
      88               0 :             if(!is_numeric($courseID) || !is_numeric($from) || !is_numeric($to) || !is_numeric($usergroup)) return null;                                                                                                                       
      89                 :                                                                                                                                                                                                                                                
      90               0 :             global $db;                                                                                                                                                                                                                        
      91               0 :             $this->news = array();                                                                                                                                                                                                             
      92               0 :             $timefrom = $this->getPeriod($courseID, $from);                                                                                                                                                                                    
      93               0 :             $timeto = $to;                                                                                                                                                                                                                     
      94                 :                                                                                                                                                                                                                                                
      95               0 :             if (!$courseID) {                                                                                                                                                                                                                  
      96                 :                 $sql =   "SELECT * FROM courses "                                                                                                                                                                                              
      97               0 :                         ."WHERE OpenDate BETWEEN '".date("Y-m-d", $timefrom) ."' "                                                                                                                                                             
      98               0 :                         ."AND '".date("Y-m-d", $timeto) ."' "                                                                                                                                                                                  
      99               0 :                         ."AND closed=0 AND Type='course' "                                                                                                                                                                                     
     100               0 :                         ."ORDER BY Opendate DESC";                                                                                                                                                                                             
     101               0 :                 $this->news["data"] = $db->get_results($sql, ARRAY_A);                                                                                                                                                                         
     102               0 :                 if ($db->num_rows == 0) $this->news = null;                                                                                                                                                                                    
     103                 :                 else {                                                                                                                                                                                                                         
     104               0 :                     $this->news["count"] = $db->num_rows;                                                                                                                                                                                      
     105                 :                     // Für jeden Kurs die UserID des Dozenten holen                                                                                                                                                                           
     106                 :                     // Bei mehreren Dozenten wird der geholt, der den Kurs angelegt hat                                                                                                                                                        
     107               0 :                     foreach($this->news["data"] as $key => $course) {                                                                                                                                                                          
     108                 :                         $sql =   "SELECT userID FROM user_course, user "                                                                                                                                                                       
     109               0 :                                 ."WHERE courseID='{$course['ID']}' "                                                                                                                                                                           
     110               0 :                                 ."AND differentUsergroup=0 "                                                                                                                                                                                   
     111               0 :                                 ."AND userID=user.ID "                                                                                                                                                                                         
     112               0 :                                 ."AND Usergroup=".DOZENT." "                                                                                                                                                                                   
     113               0 :                                 ."ORDER BY user_course.regtime LIMIT 1";                                                                                                                                                                       
     114               0 :                         $userID = $db->get_var($sql);                                                                                                                                                                                          
     115               0 :                         $this->news["data"][$key]["userID"] = $userID;                                                                                                                                                                         
     116                 :                         $sql =   "SELECT COUNT(*) FROM user_course_wait "                                                                                                                                                                      
     117               0 :                                 ."WHERE userID='".Data::toMysql($this->userID)."' "                                                                                                                                                            
     118               0 :                                 ."AND courseID='{$course['ID']}'";                                                                                                                                                                             
     119               0 :                         $this->news["data"][$key]["waiting"] = (bool)$db->get_var($sql);                                                                                                                                                       
     120               0 :                         $this->users[$userID] = $userID;                                                                                                                                                                                       
     121               0 :                     }                                                                                                                                                                                                                          
     122                 :                 }                                                                                                                                                                                                                              
     123               0 :             }                                                                                                                                                                                                                                  
     124               0 :         }                                                                                                                                                                                                                                      
     125                 :                                                                                                                                                                                                                                                
     126               0 :         return $this->news;                                                                                                                                                                                                                    
     127                 :     }                                                                                                                                                                                                                                          
     128                 :     /**                                                                                                                                                                                                                                        
     129                 :      * @see NewsCategory                                                                                                                                                                                                                       
     130                 :      */                                                                                                                                                                                                                                        
     131                 :     protected function echoNewsEntry($entry, $courseID, $usergroup = null)                                                                                                                                                                     
     132                 :     {                                                                                                                                                                                                                                          
     133               0 :         if(!isset($entry) || !isset($courseID) || !isset($this->news["user"])) return;                                                                                                                                                         
     134                 :                                                                                                                                                                                                                                                
     135               0 :         $closed = "";                                                                                                                                                                                                                          
     136               0 :         if (strtotime($entry["CloseDate"]." 23:59:59") < time())                                                                                                                                                                               
     137               0 :         {                                                                                                                                                                                                                                      
     138                 :             $closed = " <span style='font-weight:normal;font-style:italic'>("                                                                                                                                                                  
     139               0 :                     . $this->translate->_("Anmeldefrist abgelaufen")                                                                                                                                                                           
     140               0 :                     . ")</span>";                                                                                                                                                                                                              
     141               0 :         }                                                                                                                                                                                                                                      
     142               0 :         elseif (($usergroup == DOZENT || $usergroup == STUDENT || $usergroup == ALUMNUS || $usergroup == SCHUELER || $usergroup == GAST) && isset($this->courses) && !in_array($entry["ID"], array_keys($this->courses)) && !$entry["waiting"])
     143                 :         {                                                                                                                                                                                                                                      
     144               0 :             $closed = " (<a href='".PATH_TO_ROOT."courses/register.php?courseID=$entry[ID]'>"                                                                                                                                                  
     145               0 :                     . $this->translate->_("Anmelden")                                                                                                                                                                                          
     146               0 :                     . "</a>)";                                                                                                                                                                                                                 
     147               0 :         }                                                                                                                                                                                                                                      
     148               0 :         $courseName = Data::toHTML("$entry[Name] ($entry[ShortName])", false);                                                                                                                                                                 
     149               0 :         $profileLink = $this->getProfileLink($this->news["user"], $entry["userID"], $courseID);                                                                                                                                                
     150               0 :         $courseInfo = Utilities::chopText($entry["Info"], 150);                                                                                                                                                                                
     151               0 :         $scriptPath = PATH_TO_ROOT."courses/courseinfo.php";                                                                                                                                                                                   
     152               0 :         $courseID = Data::toHTML($entry["ID"], false);                                                                                                                                                                                         
     153                 :                                                                                                                                                                                                                                                
     154               0 :         $g_ZurKursInfo = $this->translate->_("Zur Kurs-Info");                                                                                                                                                                                 
     155               0 :         $g_Lesen = $this->translate->_("Lesen");                                                                                                                                                                                               
     156                 :                                                                                                                                                                                                                                                
     157               0 :         eval($this->newsTemplate->GetTemplate());                                                                                                                                                                                              
     158               0 :     }                                                                                                                                                                                                                                          
     159                 : }                                                                                                                                                                                                                                              

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.